package ACWing.TheNnderlyingAlgorithm.位运算;
//801.二进制中1的个数

import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2022/11/26 9:49
 */
public class TheNumberOFOnesINBinary {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[]arr=new int[n];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();

        }
        for (int i = 0; i < n; i++) {
            //System.out.print(nums(arr[i])+" ");//朴素写法
            int sum=0;//优雅做法（模拟lowbit的原理）
            while (arr[i]>0){
                arr[i]-=arr[i]&-arr[i];//-arr[i]=~arr[i]+1取反加一
                sum++;
            }
            System.out.print(sum+" ");
        }
    }
    public static int nums(int a){//化简成二进制并计算1出现的次数
        int sum=0;
        while (a>0){
            int x=a%2;
            if(x==1){
                sum++;
            }
            a=a/2;
        }
        return sum;
    }

}
